<?php
namespace app\api\controller;

class Index {

    public function zbs(){
        $weeks = ["日","一","二","三","四","五","六"];
        //当前时间戳
        $curtimestamp = time()-2*3600;
        $ymds = db('livedata' , [] , false)->field('ymd')->where('ts' , '>' ,$curtimestamp )->group('ymd')->select();

        $data = [];
        foreach($ymds as $key => $value){
            $item_ymd = $value['ymd'];
            $btitle = $item_ymd.' 星期' . $weeks[date('w' , strtotime($item_ymd))]; 
            if($key == 0){
                $btitle .= ' 今天';
            }
            $livelist = db('livedata' , [] , false)->where('ts' , '>' ,$curtimestamp)->where('ymd' , $item_ymd)->order('ts asc')->select(); 
            $data[] = [
                'item_ymd' => $item_ymd,
                'btitle' => $btitle,
                'livelist' => $livelist
            ];
        }
        return json(['status'=>1 , 'msg'=>'succss' , 'data' => $data]);
    }
}